
#include<iostream>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
using namespace std;




int main()
{
	int n;
	cin >> n;
	vector<int>dp(n);
	vector<int>path(n, -1);

	auto findroot = [&](int x)
		{
			while (path[x] > 0)
			{
				x = path[x];  
			}
			return x;
		};
	auto unionset = [&](int x, int y)
		{
			int root1 = findroot(x);
			int root2 = findroot(y);
			if (abs(path[root1]) < abs(path[root2]))
			{
				swap(root1,root2);
			}
			//小集合服从大集合
			if (root1 != root2)
			{
				path[root1] += path[root2];     
				 path[root2]= root1;
			}
			//cout << path[root1] << " " << path[root2] << endl;   
		};

	unionset(1, 2); 
	unionset(1,3);
	unionset(4, 3);
	for (int i = 0; i < n; i++)
	{
		if (path[i] == -1)
		{
			cout << i << "是根节点" << endl; 
		}
		else
		cout << i<<"父节点是: " << path[i] << endl;
	}
	return 0;
}

